<?php
namespace app\friend\controller;

use app\friend\controller\Index;

class Publish extends Index
{
    public function _initialize()
    {
        parent::_initialize();
    }
    
    public function index()
    {
        $this->assign('items', model('friend/Form','loglic')->publish('index'));
        
        $this->seo('publish');
        
        return $this->fetch();
    }
    
    public function save()
    {
        //表单数据
        $post = input('post.');
        
        //表单过滤
        $keys = model('friend/Form','loglic')->keys('publish','index');
        $post = DcArrayFilter($post,$keys);
        
        //验证码
        if( DcBool(config('common.site_captcha')) ){
            if(captcha_check($post['info_captcha']) == false){
                $this->error( DcError(lang('user_captcha_error')) );
            }
        }
        
        //数据库
        if( !friendSave($post) ){
            $this->error(\daicuo\Info::getError());
        }
        $this->success(lang('success'));
    }
}